<div class='head'>$lang.get('user.edit.title')</div>

#parse('/widget/widget.message.html')

<div class='tabs'>
	<a href='/admin/user'>$lang.get('a.user')</a>
	<a href='/admin/user/edit?id=$id' class='selected'>$lang.get('a.edit')</a>
</div>

<form action='/admin/user/edit'  method='post' class='form' >
	<input type='hidden' name="id" value="$id"/>
	<div><label><h3>$lang.get('user.name')</h3>:<i>$!name</i></label></div>
	<div><label><h3>$lang.get('user.nickname')</h3>:<input type='text' name='nickname' value='$!nickname'/></label></div>
	<div><label><h3>$lang.get('user.title')</h3>:<input type='text' name='title' value='$!title' /></label></div>
	<div><label><h3>$lang.get('user.email')</h3>:<input type='email' name='email' value= '$!email' /></label></div>
	<div><label><h3>$lang.get('user.phone')</h3>:<input type='tel' name='phone' value= '$!phone' /></label></div>

	<div><label><h3>$lang.get('user.lock')</h3>:</label><input type="checkbox" name='locked' #if($locked=='on' || $locked==1) checked #end /></label></div>
	<div><label><h3>$lang.get('user.failtimes')</h3>:</label><input type="text" name='failtimes' value='$!failtimes' /></label></div>

	<table id='user-table' class='tablesorter' border="0" cellpadding="0" cellspacing="1">
		<thead>
			<tr>
				<th>$lang.get('role.name')</th>
			</tr>
		</thead>
		<tbody>
	#foreach($r in $roles)
		<tr>
			<td><label><input type="checkbox" name="role" value="$r.id" #if($u.isRole($r)) checked="true" #end>$r.name</label></label></td>
		</tr>
	#end
		</tbody>
	</table>

	<table id='token-table' class='tablesorter' border="0" cellpadding="0" cellspacing="1">
		<thead>
			<tr>
				<th>$lang.get("user.ip")</th>
				<th>$lang.get("user.sid")</th>
				<th>$lang.get("user.token")</th>
				<th>$lang.get("user.expired")</th>
			</tr>
		</thead>
		<tbody>
	#foreach($r in $u.tokens)
		<tr>
			<td>$!r.ip</td>
			<td>$!r.sid</td>
			<td>$!r.token</td>
			<td>$lang.format($r.expired, 'yyyy-MM-dd HH:mm:ss')</td>
		</tr>
	#end
		</tbody>
	</table>

	<div class='btns'>
		<button class='btn btn-success' type='submit'>$lang.get('btn.save')</button>
		<a class='btn btn-warning' href='javascript:;' onclick="_showpassword()">$lang.get('a.password')</a>		
	</div>
	
</form>

<div id='password' title="$lang.get('user.edit.password')" style="display:none">
	<div><label><h3>$lang.get('user.new.password'):</h3><input type='password' name='password' value=''/></label></div>
	<button onclick='_password();'>$lang.get('btn.ok')</button>
</div>

<script>
function _showpassword() {
	$('#password').dialog({modal : true,close:function(e,ui){$(this).dialog('destroy');}});
}
function _password() {
	$('#password').dialog('close');
	var v = $('#password input[name=password]').val();
	$.post('/admin/user/edit', {id:"$id",password:v}, function(d){
		if(d.state == 200) {
			$.message("$lang.get('save.success')");
		} else {
			$.error(d.message);
		}
	})
}
</script>
